var a = getApp();

Page({
    data: {
        arr: [],
        name: "请选择",
        nameID: "",
        serviceUnit: "次",
        input: "",
        hiddenmodalput: !0
    },
    click: function(a) {
        var t = this;
        wx.showActionSheet({
            itemList: t.data.WGender,
            success: function(a) {
                console.log(a.tapIndex);
                var e = a.tapIndex;
                t.setData({
                    name: t.data.WGender[e],
                    nameID: t.data.WGenderID[e]
                }), console.log(t.data.nameID);
            }
        });
    },
    input: function(a) {
        console.log(a.detail.value), this.setData({
            input: a.detail.value
        });
    },
    ClaccAdd: function(t) {
        var e = wx.getStorageSync("log") || "", n = this;
        console.log(n.data.name), console.log(n.data.input), "请选择" == n.data.name ? (console.log(1111), 
        wx.showToast({
            title: "请选着咨询类型",
            icon: "none",
            duration: 2e3
        })) : n.data.input.length < 1 ? wx.showToast({
            title: "请输入金额",
            icon: "none",
            duration: 2e3
        }) : n.data.input.length >= 1 && n.data.name.length >= 1 && wx.request({
            url: a.globalData.dic + "doctor/prove/addServiceItem/" + e,
            data: {
                cdInterroga: n.data.nameID,
                nmInterroga: n.data.name,
                serviceUnit: n.data.serviceUnit,
                servicePrice: 100 * n.data.input
            },
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function(a) {
                console.log(a), n.onClock();
            }
        });
    },
    onLoad: function(t) {
        var e = this;
        wx.request({
            url: a.globalData.dicc + "dic/comdicbase",
            data: {
                code: 29e4
            },
            success: function(a) {
                var t = a.data.data, n = [], o = [];
                for (var c in t) n.push(t[c]), o.push(c);
                e.setData({
                    WGender: n,
                    WGenderID: o
                });
            }
        }), e.onClock();
    },
    onClock: function(t) {
        var e = wx.getStorageSync("log") || "", n = this;
        wx.request({
            url: a.globalData.dic + "doctor/prove/listServiceItem/" + e,
            success: function(a) {
                console.log(a.data.data), n.setData({
                    arr: a.data.data
                });
            }
        });
    },
    alter: function(a) {
        this.setData({
            hiddenmodalput: !this.data.hiddenmodalput
        }), console.log(a.currentTarget.dataset), this.setData({
            cdinterroga: a.currentTarget.dataset.cdinterroga,
            id: a.currentTarget.dataset.id,
            nminterroga: a.currentTarget.dataset.nminterroga,
            serviceunit: a.currentTarget.dataset.serviceunit
        });
    },
    modalInput: function(a) {
        console.log(a.detail.value), this.setData({
            serviceprice: a.detail.value
        });
    },
    cancel: function() {
        this.setData({
            hiddenmodalput: !0
        });
    },
    confirm: function() {
        var t = this;
        t.setData({
            hiddenmodalput: !0
        });
        var e = wx.getStorageSync("log") || "";
        wx.request({
            url: a.globalData.dic + "doctor/prove/updateServiceItem/" + e,
            data: {
                cdInterroga: t.data.cdinterroga,
                id: t.data.id,
                nmInterroga: t.data.nminterroga,
                servicePrice: 100 * t.data.serviceprice,
                serviceUnit: t.data.serviceunit
            },
            success: function(a) {
                console.log(a.data), t.onClock();
            }
        });
    },
    backtrack: function(a) {
        wx.setStorageSync("backtrack", 1), wx.navigateBack({
            delta: 1
        });
    }
});